<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ include file="/pages/common/taglibs.jsp" %>
<s:bean name="com.admission.util.ArrayUtils" var="data"></s:bean>
<s:set var="arraymap" value="#data.getMap()" ></s:set>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>广东工业大学招生办后台管理</title>
<link rel="stylesheet" href="${ctx }/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="${ctx }/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="${ctx }/kindeditor/lang/zh_CN.js"></script>
	<script type="text/javascript" src="${ctx }/js/jquery.js"></script>
    <script type="text/javascript" src="${ctx }/js/jquery.form.js"></script>
<script>
	
</script>
<script type="text/javascript">
 var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="entity.content"]', {
			cssPath : '${ctx}/kindeditor/plugins/code/prettify.css',
				uploadJson :  '${ctx}/kindeditor/jsp/upload_json.jsp',  
				fileManagerJson : '${ctx}/kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['messageform'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['messageform'].submit();
					});
				}
			});
			prettyPrint();
		});
function sendMessage(){
 var d=$("#messageform").serialize();
/*  var content1=document.getElementsById("content");
 if(editor.isEmpty()){
			alert("请输入内容！");
			return false;
		} */
 							
	$.post("${ctx}/admin/environment-admin!checkType.action", d ,function callback(text){
	 var content1=document.messageform.content.value;
             		if(text == "true"){
             			 editor.sync();  
                   document.forms['messageform'].submit(); 
             		}else{
             			alert("该类型已添加，请选择其他类型！");
             		}
             	});
}
function del(){
	if(confirm("请删除后再进行添加！"))
	return true;
	else
	return false;
}
</script>
</head>

<body>
	<div class="article">
		<form action="environment-admin!save.action" enctype="multipart/form-data" id="messageform" name="messageform" method="post">
		<input type="hidden" name="value" value="${value}"/>
			<table style="width:100%">
				<tr>
					<td>类型：</td>
					<td>
						<s:if test="entity.id==null">
						<select name="entity.type"  style="width:100%" id="type">
						<%-- <s:iterator value="schoollife" >
						 	<s:iterator value="value" >
							<option value="<s:property value="value" />"><s:property value="value" /></option>
							</s:iterator>
						</s:iterator> --%>
						<s:iterator value="arrayList">
						<option value="${itemName}">${itemValue}</option>
						</s:iterator>
						</select>
						</s:if>
						<s:else>
						<input type="hidden" name="id" value="${id}"/>
						 <s:property value="#arraymap.get(type)" />
						</s:else>
					</td>
				</tr>

				<tr>
					<td>介绍：</td>
					<td>
						<textarea name="entity.content" id="content" style="width:100%;height:400px">${entity.content }</textarea>
					</td>
				</tr>
				
				 <s:if test="entity.id==null">
				<tr>
					<td>图片1</td>
					<td> 
						<input type="file" name="subPicture"  /> 
						介绍：<input type="text" name="title"/>
					</td>
						
				</tr>
				<tr>
					<td>图片2</td>
					<td> 
						<input type="file" name="subPicture"  />
						介绍：<input type="text" name="title"/>
					</td>
				</tr>
				<tr>
					<td>图片3</td>
					<td> 
						<input type="file" name="subPicture"  />
						介绍：<input type="text" name="title"/> 
					</td>
				</tr>
				<tr>
					<td>图片4</td>
					<td> 
						<input type="file" name="subPicture"  /> 
						介绍：<input type="text" name="title"/>
					</td>
						
				</tr>
				</s:if>
				<s:if test="entity.id!=null">
				
				<%int i=1; %>
				<s:iterator value="pictures">
				<tr>
					<td>图片<%=i++ %></td>
					<td> 
						<img src="${ctx}/upload/${url}" width="410" height="220"/>
						介绍：${title}
						<!-- <input type="file" name="subPicture"  />  -->
						<a href="environment-admin!deleteById.action?ids=${id}&id=${environment.id}&value=${value}" onclick="return del();">删除</a> 
					</td>
				</tr>
			</s:iterator>
			<%for(;i<5;){ %>
				<tr>
					<td>图片<%=i++ %></td>
					<td> 
						<input type="file" name="subPicture"  /> 
						介绍：<input type="text" name="title"/>
					</td>
				</tr>
				<% }%>
			</s:if>
				<tr>
					<td></td>
					<td>
					<input type="button" value="确定" onclick="return sendMessage()" style="float:right;width:100px;"/>
					</td>
				</tr>
			</table>
				

		</form>
	</div>
</body>
</html>
 